/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.maternity.componentes.menu;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Aluno
 */
public class MenuList {

    public static String render(String currentPage, Integer tipoUsuario) {
        String menu = "<ul>";
        for (MenuItem i : listItens(tipoUsuario)) {
            menu += i.render(currentPage.contains(i.getLink().replace("@", "")));
        }

        menu += "</ul>";

        return menu;
    }

    private static List<MenuItem> listItens(Integer tipoUsuario) {
        List<MenuItem> l = new ArrayList<MenuItem>();
        List<MenuItem> children = new ArrayList<MenuItem>();
        if (tipoUsuario == 0) {
            children.add(new MenuItem("Médico", "@relatorios/listagemMedicos.jsp", null));
            children.add(new MenuItem("Enfermeira", "@relatorios/listagemEnfermeiras.jsp", null));
            children.add(new MenuItem("Exame", "@relatorios/listagemExames.jsp", null));
            l.add(new MenuItem("Cadastros", "#", children));
        }
        if (tipoUsuario == 0 || tipoUsuario == 1) {
            l.add(new MenuItem("Atendimentos", "@relatorios/listagemPacientes.jsp", null));
        }
        if (tipoUsuario == 0 || tipoUsuario == 3) {
            children = new ArrayList<MenuItem>();
            children.add(new MenuItem("Triagem", "@relatorios/listagemTriagem.jsp", null));
            children.add(new MenuItem("Obstetra", "@relatorios/listagemEnfObstetria.jsp", null));
            l.add(new MenuItem("Enfermeira", "#", children));
        }
        if (tipoUsuario == 0 || tipoUsuario == 2) {
            l.add(new MenuItem("Avaliação Médica", "@relatorios/listagemAvaliacao.jsp", null));
        }

        return l;
    }
}
